<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.org/schema/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui" 
	template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="usuario" styleClass="edit">
			<p:tabView>
				<p:tab title="Informações Básicas">
					<p:panel>
						<f:facet name="header">#{usuarioHome.managed ? 'Edit' : 'Add'} Usuario</f:facet>




						<s:decorate id="matriculaField" template="/layout/edit.xhtml">
							<ui:define name="label">Matricula</ui:define>
							<p:inputTextarea id="matricula" cols="80" rows="1"
								value="#{usuarioHome.instance.matricula}" />
						</s:decorate>


						<s:decorate id="nomeField" template="/layout/edit.xhtml">
							<ui:define name="label">Nome</ui:define>
							<p:inputTextarea id="nome" cols="80" rows="1"
								value="#{usuarioHome.instance.nome}" />
						</s:decorate>


						<s:decorate id="senhaField" template="/layout/edit.xhtml">
							<ui:define name="label">Senha</ui:define>
							<p:inputTextarea id="senha" cols="80" rows="1"
								value="#{usuarioHome.instance.senha}" />
						</s:decorate>
						<s:decorate id="dinamicaField" template="/layout/edit.xhtml">
							<ui:define name="label">Administrador</ui:define>
							<p:selectBooleanCheckbox id="admin"
								value="#{usuarioHome.instance.admin}">

							</p:selectBooleanCheckbox>
						</s:decorate>
						<s:decorate id="dataCriacaoField" template="/layout/edit.xhtml">
							<ui:define name="label">Data criação</ui:define>
							<h:outputText value="#{usuarioHome.instance.dataCriacao}">
								<s:convertDateTime type="both" dateStyle="short" />
							</h:outputText>

						</s:decorate>

						<div style="clear: both">
							<span class="required">*</span> Campos Obrigatórios
						</div>

					</p:panel>

					<div class="actionButtons">

						<p:commandButton id="save" value="Salvar"
							action="#{usuarioHome.persist}" disabled="#{!usuarioHome.wired}"
							rendered="#{!usuarioHome.managed}">
							<s:conversationId />
						</p:commandButton>

						<p:commandButton id="update" value="Salvar"
							action="#{usuarioHome.update}" rendered="#{usuarioHome.managed}">
							<s:conversationId />
						</p:commandButton>

						<p:commandButton id="delete" value="Deletar"
							action="#{usuarioHome.remove}" immediate="true"
							rendered="#{usuarioHome.managed}" />

						<p:button id="cancelEdit" value="Voltar" propagation="end"
							outcome="/pages/UsuarioList.xhtml" rendered="#{usuarioHome.managed}" />

						<p:button id="cancelAdd" value="Voltar" propagation="end"
							outcome="/pages/#{empty usuarioFrom ? 'UsuarioList' : usuarioFrom}.xhtml"
							rendered="#{!usuarioHome.managed}" />

					</div>
				</p:tab>

				<p:tab title="Simulados">
					<p:panel>
						<f:facet name="header">Simulados cadastrados para o usuário</f:facet>
						    <h:outputText value="Não existem simulados cadastrados para esse usuário"
               								rendered="#{empty usuarioHome.instance.simulados}"/>
						<p:dataTable
							value="#{usuarioHome.instance.simulados.toArray()}"
							var="_simulado" rowKeyVar="row" rendered="#{not empty usuarioHome.instance.simulados}">
							<p:column>
								<ui:define name="header">#</ui:define>
								<h:outputText value="#{row}" />
							</p:column>
							<p:column>
								<ui:define name="header">Descrição</ui:define>
								<h:outputText value="#{_simulado.descricao}" />
							</p:column>
							<p:column>
								<ui:define name="header">Data Validade</ui:define>
								<h:outputText value="#{_simulado.disponivel_ate}">
									<s:convertDateTime type="both" dateStyle="short" />
								</h:outputText>
							</p:column>
						</p:dataTable>
					</p:panel>
				</p:tab>
			</p:tabView>

		</h:form>

	</ui:define>

</ui:composition>
